package ${package.ServiceImpl};

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mybatisplus.common.model.param.ParamBean;
import com.mybatisplus.common.page.PageInfo;
import com.mybatisplus.common.page.PageVo;
import org.springframework.beans.factory.annotation.Autowired;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import ${package.Entity}.${entity};
import ${package.Mapper}.${table.mapperName};
import ${package.Service}.${table.serviceName};
import ${superServiceImplClassPackage};

import java.util.List;


@Slf4j
@Service
<#if kotlin>
<#else>
public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.mapperName}, ${table.entityName}> implements ${table.serviceName} {

    @Autowired
    private ${table.mapperName} ${table.name}Mapper;

    @Override
    public List<${table.entityName}> queryList() {
        QueryWrapper<${table.entityName}> queryWrapper = new QueryWrapper<>();
        List<${table.entityName}> selectList = ${table.name}Mapper.selectList(queryWrapper);
        return selectList;
    }

    @Override
    public Boolean changeById(${table.entityName} ${table.name}) {
        int i = ${table.name}Mapper.updateById(${table.name});
        return true;
    }

    @Override
    public Boolean removeById(Long id) {
        int i = ${table.name}Mapper.deleteById(id);
        return true;
    }

    @Override
    public Boolean saveData(${table.entityName} ${table.name}) {
        int insert = ${table.name}Mapper.insert(${table.name});
        return true;
    }

    @Override
    public PageVo page(ParamBean<${table.entityName}> paramBean){
        PageVo<${table.entityName}> pageVo = new PageVo<>();
        PageInfo pageInfo = new PageInfo();
        Page<${table.entityName}> page = new Page<>(paramBean.getPageNum(), paramBean.getPageSize());
        QueryWrapper<${table.entityName}> queryWrapper = new QueryWrapper<>();
        ${table.name}Mapper.selectPage(page,queryWrapper);
        pageVo.setDatas(page.getRecords());
        pageInfo.setTotalPageNum(Integer.valueOf(page.getTotal()+""));
        pageVo.setPageInfo(pageInfo);
        return pageVo;
    }
}
</#if>